﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using GreatB2C.Config.SiteInfo;

namespace GreatB2C.Web.Manage.SystemSet.SiteInfo
{
    public partial class SiteInfo : Inherit.ManagePage
    {
        protected void Page_Load( object sender , EventArgs e )
        {
            if ( !IsPostBack )
            {
                LoadSetting( );
            }
        }

        protected void LoadSetting( )
        {
            txtSiteName.Text = UIConfig.SiteName;
            txtSiteTitle.Text = UIConfig.SiteTitle;
            txtSiteUrl.Text = UIConfig.SiteAddress;
            txtLogoUrl.Text = UIConfig.LogoAddress;
            txtBannerUrl.Text = UIConfig.BannerAddress;
            txtWebmaster.Text = UIConfig.MasterName;
            txtWebmasterEmail.Text = UIConfig.MasterEmail;
            txtCopyright.Text = UIConfig.Copyright;
            txtMeta_Keywords.Text = UIConfig.SiteMeta;
            txtMeta_Description.Text = UIConfig.MetaDescription;
        }

        protected void BtnSubmit_Click( object sender , EventArgs e )
        {
            bool isSuccess = UIConfig.Config( txtSiteName.Text.Trim( ) , txtSiteTitle.Text.Trim( ) , txtSiteUrl.Text.Trim( )
                , txtLogoUrl.Text.Trim( ) , txtBannerUrl.Text.Trim( ) , txtWebmaster.Text.Trim( ) , txtWebmasterEmail.Text.Trim( )
                , txtCopyright.Text.Trim( ) , txtMeta_Keywords.Text.Trim( ) , txtMeta_Description.Text.Trim( ) );

            if ( isSuccess )
            {
                Response.Redirect( "../../Message.aspx?msg=" + Server.UrlEncode( "网站信息配置成功！" ) + "&rtn=SystemSet/SiteInfo/SiteInfo.aspx" );
            }
            else
            {
                Response.Redirect( "../../Message.aspx?msg=" + Server.UrlEncode( "网站信息配置失败，请联系管理员！" ) + "&rtn=SystemSet/SiteInfo/SiteInfo.aspx" );
            }
        }
    }
}
